Repository navigation
feat(fleet): mirror placement sessions to the queue backend (placement_sessions) — #13146 slice 1 - #13169
Conversation
…t_sessions) — #13146 slice 1 - turso_queue: placement_sessions table in SCHEMA plus /placement-put|get|list|sync verbs (sync is insert-or-ignore: the migration path for pre-existing local stores) - client transport: broker_roundtrip_bounded — same routes as the queue client, caller-budget timeouts, errors returned, never dies, never spawns the session broker - placement: the local JSON store stays the commit and the only decision input; records mirror best-effort (put on commit and refresh, get/list merged by updated_at, an opportunistic sync sweep migrates pre-existing local stores); FLEET_PLACE_REMOTE=off disables the mirror - runbook: session-store paragraph updated for the mirror; the broadcast string gains the binary-acquisition block (bootstrap pin plus the release-asset route for non-Muse machines)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eca57d1b5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mirrored = remote.get(handle).ok().flatten(); | ||
| remote::pick_session(local, mirrored) |
There was a problem hiding this comment.
Resolve mirrored followup records during actual dispatch
When a handle exists only in the backend because it was dispatched from another seat, a dry-run followup succeeds through this lookup, but adding --dispatch selects the earlier local-only branch. That branch calls refresh_session before importing the mirrored record and fails with “no session with handle”. Resolve and seed the mirrored record before the dispatch/dry-run split so cross-seat followups work without requiring a separate session status call first.
Useful? React with 👍 / 👎.
| ON CONFLICT(handle) DO UPDATE SET \ | ||
| record = excluded.record, state = excluded.state, \ | ||
| surface = excluded.surface, submitted_by = excluded.submitted_by, \ | ||
| run_id = excluded.run_id, updated_at = excluded.updated_at"; |
There was a problem hiding this comment.
Reject stale records in the placement-session upsert
When two seats refresh the same running session concurrently, one can publish a newer completed record while the other's delayed GitHub request fails. GithubActionsAdapter::run_state preserves the input state on failure, and run_session still puts that unchanged older record. This unconditional upsert then replaces the completed backend record with the older running state and timestamp, defeating the newer-record selection used by readers. Guard conflict updates against timestamps older than the stored record.
Useful? React with 👍 / 👎.
| recs.sort_by(|a, b| created_at(b).cmp(created_at(a))); | ||
| recs.truncate(SYNC_BATCH); | ||
| let _ = remote.sync(&recs); |
There was a problem hiding this comment.
Advance migration sweeps beyond the newest 100 sessions
For an existing local store containing more than 100 sessions, every sweep selects exactly the same newest 100 records. Once those are inserted, subsequent insert-or-ignore calls keep resending them, so older records never reach the backend and their handles remain unavailable from other seats. Track migration progress or rotate through bounded batches so repeated successful sweeps eventually cover the whole store.
Useful? React with 👍 / 👎.
| let mut s = UnixStream::connect(socket).map_err(|e| { | ||
| format!( | ||
| "cannot connect to queue-broker at unix://{}: {e}", | ||
| socket.display() | ||
| ) | ||
| })?; |
There was a problem hiding this comment.
Bound Unix-socket connection attempts before blocking
When the configured broker's Unix-socket accept backlog is full, UnixStream::connect blocks until the server accepts a connection; the read/write timeouts installed afterward cannot interrupt it. The session-proxy leg uses the same blocking connection pattern. A stalled broker can therefore hang a dispatch indefinitely during its synchronous mirror call instead of falling back after the five-second budget. Use a deadline-aware nonblocking connection for both Unix-socket legs and ensure route probing is bounded too.
Useful? React with 👍 / 👎.
Slice 1 of #13146: placement session records gain their designed
home in the queue backend, while placement itself stays exactly as
decentralized as today.
Backend (turso_queue)
placement_sessionstable added to the SCHEMA set (created byensure_schemaon broker start): the full client record JSON inrecord, with handle/state/surface/submitted_by/run_id extractedas columns for list/filter queries.
verb:
/placement-put(upsert by handle),/placement-get,/placement-list(newest first, bounded),/placement-sync(insert-or-ignore batch — the migration path; it can never
overwrite a row the backend already holds).
Client transport
broker_roundtrip_bounded: the queue client's routes with acaller-set budget on every leg, HTTP errors returned as Err
(the unbounded legs die with exit 3), no session-broker
auto-spawn, and a malformed broker URL degrading to Err.
Placement
placement decisions (
build_ctx, the Blacksmith reconcile readlocal state exactly as before).
status/result/followup reads take the newer of the local and
backend copies (by
updated_at);session listunions bothstores; an insert-or-ignore sync sweep after dispatch and on
list migrates pre-existing local stores with no operator step.
FLEET_PLACE_REMOTE=offdisables the mirror (operator + testescape hatch).
Runbook (
pkgs/fleet/doc/agents/remote-build-and-test.md):the session-store paragraph now describes the mirror + fallback,
and the broadcast string gains the binary-acquisition block —
bootstrap pin, plus the release-asset route for machines without
the Muse bootstrap (tag read from the
FLEET_URL/FLEET_SHA256pin block in
scripts/muse/bootstrap.sh; verify against the.sha256asset; verify the install withfleet queue dispatch --helpandfleet queue surfaces).Verification
the stub pipeline (SQL shape + reply mapping), 4 mirror tests
(pick/merge/sync against a fake remote), the commit wiring test
(local commit identical with the mirror up or down), 2 bounded
transport tests (silent-peer timeout; HTTP error as Err).
Targeted local run: placement filter 54 passed, bounded 4
passed, 0 failed.
(handle
fp_6f8b3d9c00902b9b10927c57db87dba8, run45150362527 on dezren39/fleet) — result recorded on impl(fleet): placement sessions to the queue backend (placement_sessions) — centralize decision state, keep placement decentralized #13146.
Live cross-seat verification (acceptance criterion 1 on #13146)
follows the normal binary rollout: the broker picks up the verbs
and seats pick up the client from main, as with every fleet
change. #13146 stays open for that record; the later slices named
there (Blacksmith minute ledger if spend grows; hard cap
enforcement) are out of scope here.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.